import sys,traceback,Ice
Ice.loadSlice("Printer.ice")
import QuerySystem 

class Client(Ice.Application):
    def run(self, args):
        if len(args) > 1:
            print(self.appName() + ": too many arguments")
            return 1

        query = None
        try:
            query =QuerySystem.QueryResultsPrx.checkedCast(self.communicator().stringToProxy("queryResults"))
        except Ice.NotRegisteredException:
            Tempquery = IceGrid.QueryPrx.checkedCast(self.communicator().stringToProxy("QueryIceGrid/Query"))
            query =QuerySystem.QueryResultsPrx.checkedCast(Tempquery.findObjectByType("::QuerySystem::QueryResults"))

        if not query:
            print(self.appName() + ": couldn't find a `::QuerySystem::QueryResults.")
            return 1
        sys.stdout.write("==> ")
        sys.stdout.flush()
        mark_dict = query.QueryByNo("2014201758")
        print(mark_dict)
app = Client()
sys.exit(app.main(sys.argv, "config.client"))
